// import "@/assets/icons/iconfont/iconfont.js";
// import '@/assets/css/icon.css';
import { createApp } from 'vue'
import ElementPLUS, { Message } from 'element-plus';
import App from './App.vue'
import router from "./router";
import piniaPlugin from "@/store/piniaPlugin.js";
import piniaPersist from 'pinia-plugin-persist'
import { createPinia } from "pinia";
// import { useAppStore } from "@/store/index";
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import vPermissionDirective from "@/directives/v-permission";
import axios from "axios";
import _ from "lodash";
//引入 icon svg插件需要配置代码
import 'virtual:svg-icons-register';


import "@/styles/index.scss";
import "./assets/css/element-reset.css";
// 引入公共scss
import "element-plus/theme-chalk/index.css";

import 'element-plus/dist/index.css'

import './assets/css/main.scss';
import locale from 'element-plus/es/locale/lang/zh-cn';
console.log(import.meta.env) //输出环境变量
// const store = useAppStore();

const pinia = createPinia();
pinia.use(piniaPersist)
const app = createApp(App);

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {//element 图标
    app.component(key, component)
}

//F5刷新返回首页
window.addEventListener('load', function () {
    let stu = location.href.split('?')[0].split('#')[1];
    if(stu!=='/dashboard' && stu !=='/'){
        location.replace(location.href.split('#')[0])
    }
    //浏览器刷新，查询记录还原默认值
   /*  if(store.tagsLists && store.tagsLists.length){
        store.tagsLists.forEach((item,index)=>{
            if(item && store[item.name + '/searchParams']){
                store[item.name + '/searchParams'] = {};
                store[item.name + '/showOtherParam'] = false;
                store[item.name + '/routeParams']= {};
                store[item.name + '/menuParams'] = {};
            }
        })
    } */
});

app
    .use(pinia)
    .use(router)
    .use(ElementPLUS, { locale })
    .directive('permission', vPermissionDirective)
    .mount('#app');

(window as any).axios = axios;
